﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DTO;
using BUS;

namespace GUI
{
    public partial class frmThemKhachHang : DevComponents.DotNetBar.Metro.MetroForm
    {
        public delegate void ThemMoi(KhachHangDTO khDTO);
        public event ThemMoi KhiThemMoi = null;

        public frmThemKhachHang()
        {
            InitializeComponent();
        }

        private void btnDongY_Click(object sender, EventArgs e)
        {
            if (txtTenKhachHang.Text == "")
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("Bạn chưa nhập tên khách hàng!", "eMobile - Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtTenKhachHang.Focus();
            }
            else
            {
                try
                {
                    KhachHangDTO khDTO = LayThongTin();
                    if (KhiThemMoi != null)
                    {
                        KhiThemMoi(khDTO);
                    }
                }
                catch (Exception ex)
                {
                    DevComponents.DotNetBar.MessageBoxEx.Show("Lỗi dữ liệu thêm nhân viên " + ex.Message);
                }
            }
        }

        KhachHangDTO LayThongTin()
        {
            KhachHangDTO khDTO = new KhachHangDTO();
            khDTO.TenKhachHang = txtTenKhachHang.Text;
            khDTO.SoDienThoai = this.txtSoDienThoai.Text;
            khDTO.DiaChi = this.txtDiaChi.Text;
            khDTO.Email = this.txtEmail.Text;
            khDTO.GhiChu = this.txtGhiChu.Text;

            return khDTO;
        }

        private void btnHuyBo_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}